-
Notifications
You must be signed in to change notification settings - Fork 17
Don't emit nested objects as document symbols #859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
698f1a3
to
f67b10f
Compare
5e3988d
to
a4f5a00
Compare
foo.detail = Some(String::from("function()")); | ||
|
||
assert_eq!(test_symbol("foo <- function() { bar <- 1 }"), vec![foo]); | ||
insta::assert_debug_snapshot!(test_symbol("foo <- function() { bar <- function() 1 }")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be worth also having a snapshot test that sets include_assignments_in_blocks
to true
if you can easily expose that toggle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. (I'm assuming you mean testing nested assignments below, rather than making extra sure we always include functions here)
// Assigned variables in nested contexts are not emitted as symbols | ||
fn test_symbol_nested_assignments() { | ||
insta::assert_debug_snapshot!(test_symbol( | ||
" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, to be super clear, at top level we do want assigned variables to be treated as symbols?
I honestly don't think that sounds super useful either
Like, a 300 line R script is bound to have a ton of assignments, and I'm not sure that seeing them in the outline feels that useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's useful at least in packages with e.g. R6 classes.
In scripts top-level assignments allow to quickly look through things like assigned data frames. But you're right that lots of variables won't be very useful to have in there.
f67b10f
to
323baa2
Compare
bc8ec87
to
db257d2
Compare
Branched from #858
Addresses posit-dev/positron#8330
Objects assigned in
{}
blocks are currently emitted as document symbols, which causes the ouline and document symbol search (@
prefix in command palette) to be quite busy:Screen.Recording.2025-06-27.at.15.18.45.mov
Here is how it looks like if we only emit top-level objects:
Screen.Recording.2025-06-27.at.15.20.35.mov
This is controllable via a new
"positron.r.symbols.includeAssignmentsInBlocks
setting. By default we don't include these nested assignments.QA Notes
You should see the new setting in the config UI:
It's documented that files need to be reopened (they can also be changed) or the server restarted for this setting to take effect.